import Vue from "vue";
import selectTreeComponent from "./selectTree";
import windowComponent from "./window";
import paginationComponent from "./pagination";
export const selectTree = {
  install: function(Vue) {
    Vue.component("selectTree", selectTreeComponent);
  }
};
export const pagination = {
  install: function(Vue) {
    Vue.component("pagination", paginationComponent);
  }
};
/**
 * @description 打开一个window
 * @param {Object} com 组件
 * @param {String} title 标题
 * @param {Object} data 参数
 */
export const window = function(com, title, data = {}) {
  if (!com) {
    return;
  }
  const component = Vue.extend(windowComponent);
  let option = Object.assign(
    { component: com },
    { title },
    { options: { ...data } }
  );
  // console.log(option);
  let instance = new component({
    el: document.createElement("div"),
    data: option
  });
  this.$el.appendChild(instance.$el);
  return instance;
};
